<?
if( !defined( 'MODULE_FILE' ) ) {
	die( "cant access file directly!" );
}

$mid 	= ( ( true == isset( $_GET['mid'] ) && true == valStr( $_GET['mid'] ) ) ? $_GET['mid'] : NULL );
$smid 	= ( ( true == isset( $_GET['smid'] ) && true == valStr( $_GET['smid'] ) ) ? $_GET['smid'] : NULL );

autoLoader();

$objobjWardCatagories 	= new BaseWardCatagories();
$objWardCatagories 		= new WardCatagories();

?>
<html>
<head>
<?php require_once 'commonJS.php'; ?>
</head>
<body>
<div style="margin-left:12px; margin-top: 10px;">
	<p>
		<a class="btn btn-outline btn-primary btn-xs" id="act" href="modules.php?file=wards_catagory&mid=<? echo $mid;?>&smid=<? echo $smid;?>" >Add New Ward Catagory</a>
		<a class="btn btn-outline btn-primary btn-xs" id="active" href="modules.php?file=view_wards_catagory&type=view&mid=<? echo $mid;?>&smid=<? echo $smid;?>" >View All Ward Catagory</a>&nbsp;
	</p>
</div>
<div class="col-lg-8">
<div class="panel panel-primary">
<div class="panel-heading"><i class="fa fa-bell fa-fw"></i>Add Ward Catagory</div>
<div class="panel-body">

<form METHOD="POST" action="modules.php?file=insert_wards_catagory&type=insert&mid=<? echo $mid; ?>&smid=<? echo $smid; ?>" id="formSubmit" name="formSubmit" >
	
		<table width="80%" cellspacing="0" cellpadding="3">

			<tr><td height="10" colspan="2"></td></tr>
			<tr valign="top">
				<td class="mandatory" width="220">Cat ID</td>
				<td>
				<?php
				$intWardCatagoryId 	= NULL;
				$strName = Null;
				$strDescription= NULL;
				$intMixBedCount= NULL;
				$intMaxBedCount= NULL;
				
				if( true == isset( $_GET['ward_cat_id'] ) && true == valStr( $_GET['ward_cat_id'] ) ) {
					$intWardCatagoryId = $_GET['ward_cat_id'];
					
					$objobjWardCatagories = $objWardCatagories->fetchWardCatagoriesById( $_GET['ward_cat_id'] );
					
					if( true == valObj( $objobjWardCatagories, 'BaseWardCatagories' ) ) {
						$strName 				= $objobjWardCatagories->getName();
						$strDescription 		= $objobjWardCatagories->getDescription();
						$intMixBedCount 		= $objobjWardCatagories->getMixBedCount();
						$intMaxBedCount 		= $objobjWardCatagories->getMaxBedCount();
					}
				} else if( true == valObj( $objobjWardCatagories, 'BaseWardCatagories' ) ) {
					$intWardCatagoryId = $objobjWardCatagories->fetchNextId();
				}
				?>
					<input id="ward_cat_id" Name="ward_cat_id" type="text" class="validate[required]" style="width:100px;" readonly="readonly" value="<?php echo $intWardCatagoryId;?>"> <label>Auto generated</label>
				</td>
			</tr>
			<tr><td height="10" colspan="2"></td></tr>
			<tr valign="top">
				<td class="mandatory" width="220">Name</td>
				<td>
					<input id="name" Name="name" type="text" class="validate[required]" style="width:202px;" value="<?php echo $strName; ?>">
				</td>
			</tr>
			<tr><td height="10" colspan="2"></td></tr>
			<tr valign="top">
				<td class="mandatory" width="220">Description</td>
				<td>
					<input id="description" Name="description" type="text" class="validate[required]" style="width:202px;" value="<?php echo $strDescription; ?>">
				</td>
			</tr>
			<tr><td height="10" colspan="2"></td></tr>
			<tr valign="top">
				<td class="mandatory" width="220">Min Bed Count</td>
				<td>
					<input id="min_bed_count" Name="min_bed_count" type="text" style="width:202px;" value="<?php echo $intMixBedCount; ?>">
				</td>
			</tr>
			<tr><td height="10" colspan="2"></td></tr>
			<tr valign="top">
				<td class="mandatory" width="220">Mix Bed Count</td>
				<td>
					<input id="mix_bed_count" Name="mix_bed_count" type="text" style="width:202px;" value="<?php echo $intMaxBedCount; ?>">
				</td>
			</tr>
			<tr><td height="10" colspan="2"></td></tr>
			<tr valign="top">
				<td class="mandatory" width="220">&nbsp;</td>
				<td>
					<?php
						if( true == isset( $_GET['ward_cat_id'] ) && true == valStr( $_GET['ward_cat_id'] ) ) {
							echo "<input type=hidden name=operation value=update>";
							echo "<input type=submit value=UPDATE id=Submit name=Submit>";
						} else {
							echo "<input type=hidden name=operation value=insert>";
							echo "<input type=submit value=SUBMIT id=Submit name=Submit>";
						}
					?>
				</td> 				
			</tr>
		</table>
	</form>
</div>
</div>
</div>	
</body>
</html>